﻿<UserControl
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:Custom="http://schemas.microsoft.com/wpf/2008/toolkit"
    x:Class="UI.Controls.UpdateDocFromWS" 
    mc:Ignorable="d"
    d:DesignWidth="320" d:DesignHeight="180"
    Loaded ="UserControl_Loaded"
	 >
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition/>
        </Grid.RowDefinitions>
        <DockPanel>
            <Button x:Name="Search" Content="Search" HorizontalContentAlignment="Center" Click="Search_Click" HorizontalAlignment="Right" Margin="10,5,5,5" MaxHeight="32" VerticalAlignment="Top" VerticalContentAlignment="Center" DockPanel.Dock="Right" />
            <WrapPanel d:LayoutOverrides="GridBox">
                <StackPanel VerticalAlignment="Top" Orientation="Horizontal">
                    <Label Content="Author:"/>
                    <TextBox x:Name="Author" TextWrapping="Wrap" MinWidth="100"/>
                </StackPanel>
                <StackPanel VerticalAlignment="Top" Orientation="Horizontal">
                    <Label Content="Title:"/>
                    <TextBox x:Name="Title" TextWrapping="Wrap" MinWidth="100"/>
                </StackPanel>
                <StackPanel VerticalAlignment="Top" Orientation="Horizontal">
                    <Label Content="ISBN:"/>
                    <TextBox x:Name="ISBN" TextWrapping="Wrap" MinWidth="100"/>
                </StackPanel>
            </WrapPanel>
        </DockPanel>
        <Label HorizontalAlignment="Left" Content="Results:" d:LayoutOverrides="Height" Grid.Row="1" />
        <DockPanel Grid.Row="2">
            <ContentControl x:Name="PageIndicator" Height="30" DockPanel.Dock="Bottom">
                <WrapPanel HorizontalAlignment="Center">
                    <TextBlock Text="{Binding ItemPage}" />
                    <TextBlock Text="/" />
                    <TextBlock Text="{Binding TotalPages}" />                    
                </WrapPanel>
            </ContentControl>
            <Button x:Name="PrevResultPage" Width="20" DockPanel.Dock="Left" Content="&lt;" Click="PrevResultPage_Click" />
            <Button x:Name="NextResultPage" Width="20" DockPanel.Dock="Right" Content="&gt;" Click="NextResultPage_Click" />
            <Custom:DataGrid x:Name="SearchResults" Grid.Row="2" AutoGenerateColumns="False" SelectionChanged="SearchResults_SelectionChanged" >
                <Custom:DataGrid.Columns>
                    <Custom:DataGridTemplateColumn Header="Cover">
                        <Custom:DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <ListBox ItemsSource="{Binding Cover}" BorderThickness="0" >
                                    <ListBox.ItemTemplate>
                                        <DataTemplate>
                                            <!--<TextBlock Text="{Binding Path.Uri}" />-->
                                            <Image Source="{Binding Path.Uri}" />
                                        </DataTemplate>
                                    </ListBox.ItemTemplate>
                                </ListBox>
                            </DataTemplate>
                        </Custom:DataGridTemplateColumn.CellTemplate>
                    </Custom:DataGridTemplateColumn>
                    <Custom:DataGridTextColumn Header="Title" Binding="{Binding Title}" />
                    <Custom:DataGridTemplateColumn Header="Authors" >
                        <Custom:DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <ListBox ItemsSource="{Binding Authors}" BorderThickness="0">
                                    <ListBox.ItemTemplate>
                                        <DataTemplate>
                                            <WrapPanel>
                                                <TextBlock Text="{Binding LastName}" />
                                                <TextBlock Text=" " />
                                                <TextBlock Text="{Binding FirstName}" />
                                            </WrapPanel>
                                        </DataTemplate>
                                    </ListBox.ItemTemplate>
                                </ListBox>
                            </DataTemplate>
                        </Custom:DataGridTemplateColumn.CellTemplate>
                    </Custom:DataGridTemplateColumn>
                    <Custom:DataGridTextColumn Header="No of Pages" Binding="{Binding NumberOfPages}" />
                    <Custom:DataGridTextColumn Header="Published" Binding="{Binding DatePublished}" />
                    <Custom:DataGridTextColumn Header="Edition" Binding="{Binding Edition}" />
                    <Custom:DataGridTextColumn Header="ISBN-13" Binding="{Binding ISBN}" />
                </Custom:DataGrid.Columns>
            </Custom:DataGrid>
        </DockPanel>
    </Grid>
</UserControl>
